package br.com.ime.usp.cmep;

import com.markupartist.android.widget.ActionBar;
import com.markupartist.android.widget.ActionBar.AbstractAction;
import com.markupartist.android.widget.ActionBar.Action;
import com.markupartist.android.widget.ActionBar.IntentAction;

import android.R.drawable;
import android.app.Activity;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class CMEPActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		ConnectionUtils.setContext(this);

		// configura actionbar
        final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
        actionBar.setTitle(getString(R.string.app_name));
        final Action otherAction = new HomeAction(this); //new IntentAction(this, new Intent(this, CMEPActivity.class), R.drawable.ic_launcher);
        actionBar.setHomeAction(otherAction);
		
		// configura botoes
		Button mapa = (Button) findViewById(R.id.menu_mapa);
		Button cardapio = (Button) findViewById(R.id.menu_cardapio);
		Button rating = (Button) findViewById(R.id.menu_rating);
		Button janus = (Button) findViewById(R.id.menu_janus); 

		mapa.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(CMEPActivity.this,MapActivity.class);
				startActivity(intent);
			}
		});

		cardapio.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(CMEPActivity.this,CardapioActivity.class);
				startActivity(intent);
			}
		});
		
		rating.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(CMEPActivity.this,RatingActivity.class);
				startActivity(intent);
			}
		});
		
		janus.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(CMEPActivity.this,JanusActivity.class);
				startActivity(intent);
			}
		});
	}
	
	
	
	// quando clica no botao Home, faz isto aqui...
    private class HomeAction extends AbstractAction {
    	private Activity act;
        public HomeAction(Activity a) {
            super(R.drawable.ic_launcher); act = a;
        }
        public void performAction(View view) {
            Toast.makeText(act, getString(R.string.app_name) + "\npor alemart, alexmorimitsu\n2012 / 1", Toast.LENGTH_LONG).show();
        }
    }
}